home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE19
/
EX6.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-14
|
3KB
|
60 lines
#include <windows.h>
#include <winreg.h>
#include <genstub.c>
LRESULT FAR PASCAL WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg )
{
case WM_COMMAND:
switch ( wParam )
{
case IDM_TEST:
{ // Test option.
LONG lRes1, lRes2; // Holds results of key finds.
char szBuffer[256]; // Buffer to store the values.
HKEY hKeyIcons; // RTF default icon key.
HKEY hKeyFileType; // RTF file key.
// Open a key for rtffile.
lRes1 = RegOpenKeyEx( HKEY_CLASSES_ROOT, // registry root
"rtffile\\DefaultIcon", // icon name
0, KEY_ALL_ACCESS, &hKeyIcons );
lRes2 = RegOpenKeyEx( HKEY_CLASSES_ROOT, // registry root
"rtffile", 0, KEY_ALL_ACCESS,
&hKeyFileType );
if ( ( lRes1==ERROR_SUCCESS ) && ( lRes2==ERROR_SUCCESS ) )
{
DWORD dwType;
LPTSTR lpszBuffer;
DWORD dwBytes = 128;
RegQueryValueEx( hKeyFileType, "", 0, &dwType,
szBuffer, &dwBytes );
// Make message.
lpszBuffer = &szBuffer[lstrlen( szBuffer )];
lstrcat( lpszBuffer, " icons are found in file " );
lpszBuffer = &szBuffer[lstrlen( szBuffer )];
dwBytes = 128;
RegQueryValueEx( hKeyIcons, "", 0, &dwType,
lpszBuffer, &dwBytes );
}
else
lstrcpy( szBuffer, "Rich Text File Information Not Found" );
// Put message to screen.
MessageBox( hWnd, szBuffer, "Registry Query", MB_OK );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default: // default windows message processing
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return( 0L );
}